package cn.springsoter.core.oss.rule.impl;

import cn.springsoter.core.oss.rule.IOssRule;
import cn.springsoter.core.tool.utils.DateUtil;
import cn.springsoter.core.tool.utils.StringPool;
import cn.springsoter.core.tool.utils.StringUtil;
import lombok.AllArgsConstructor;

/**
 * 默认存储桶生成规则
 *
 * @author Kevin
 */
@AllArgsConstructor
public class OssRuleImpl implements IOssRule {

	@Override
	public String bucketName(String bucketName) {
		return bucketName;
	}

	@Override
	public String fileName(String originalFilename) {
		//生成结果示例：upload/20210101/8140d99fa77047168dd619eef3760322.jpg
		return "upload" + StringPool.SLASH + DateUtil.today() + StringPool.SLASH + StringUtil.randomUUID() + StringPool.DOT + StringUtil.getExtensionName(originalFilename);
	}

}
